<template>
  <!-- html -->
  <div class="person">
    <h1>有个人叫{{ person.name }},现在{{ person.age }}岁</h1>
    <button @click="changeAge">修改年龄</button>
    <ul>
      <li v-for="st in stu" :key="st.id">{{ st.name }}</li>
    </ul>
    <button @click="changeName">修改</button>
    <hr />
    <h2>{{ a.b.c }}</h2>
  </div>
</template>

<script lang="ts" setup name="Person">
import { reactive } from "vue";

let person = reactive({ name: "xiaoji", age: 18 });

let stu = reactive([
  { id: 1, name: "xiaoqin", age: 11 },
  { id: 2, name: "xiaoli", age: 12 },
  { id: 3, name: "xiaowang", age: 32 },
]);

//深层次
let a = reactive({
  b: {
    c: "和尚",
  },
});

function changeAge() {
  person.age += 1;
}
function changeName() {
  stu[0].name = "小琴";
}
</script>

<style scoped>
/* 样式 */
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}
button {
  margin: 0 5px;
}
</style>
